package com.mvc.frame.ctrl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mvc.frame.iserv.IRestServ;
import com.mvc.frame.sys.AjaxResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/rest")
@Api(tags="Rest业务")
public class RestCtrl extends AjaxResult
{
	@Autowired
	private IRestServ iRestServ;
	
    @ApiOperation(value="添加用户信息")
    @ApiImplicitParams({
    	 @ApiImplicitParam(name="name",value="用户名称",required=true,paramType="query"),
    	 @ApiImplicitParam(name="age",value="用户年龄",required=true,paramType="query",dataType="Integer")
    })
    @PostMapping("/getpo")
	public Object getPostObj(String name,Integer age)
	{
    	Map<String, Object> result=iRestServ.getPostObj(name,age);
		return super.ajaxResultSuccess(result);
	}
    @ApiOperation(value="获取用户信息")
    @ApiImplicitParams({
    	 @ApiImplicitParam(name="id",value="用户ID",required=true,paramType="query",dataType="Integer"),
    })
    @GetMapping("/getui")
	public Object getUserInfo(Integer id)
	{
    	Object result=iRestServ.getUserInfo(id);
		return super.ajaxResultSuccess(result);
	}
    
    @ApiOperation(value="异常测试")
    @ApiImplicitParams({
    	 @ApiImplicitParam(name="id",value="用户ID",required=true,paramType="query",dataType="Integer"),
    })
    @GetMapping("/getex")
	public Object getEx(Integer id)
	{
    	Integer result=id/0;
		return super.ajaxResultSuccess(result);
	}
}
